<template>
	<view style="padding-bottom: 150rpx;" v-if="pageShow">
		<!-- 待支付 -->
		<view class="mainpadding flexleft" style="background-color: #3478f5;min-height: 170rpx;"
			v-if="dataAll.pay_status==1">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">待支付</view>
				<view class="xiaobai strongtext margin_top">等待买家支付
				</view>
			</view>
		</view>
		<!-- 待发货 -->
		<view class="mainpadding flexbetween" style="background-color: #3478f5;min-height: 170rpx;"
			v-if="dataAll.pay_status==2">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">已付款</view>
				<view class="xiaobai strongtext margin_top">已付款，查看支付凭证后确认收款</view>
			</view>
			<!-- <u-icon name="car-fill" color="#ffffff" size="40"></u-icon> -->
		</view>
		<!--待评价 -->
		<view class="mainpadding flexleft" style="background-color: #3478f5;min-height: 170rpx;"
			v-if="dataAll.pay_status==3">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">已完成</view>
				<view class="xiaobai strongtext margin_top">订单已完成</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="margin_top2 flexbetween">
				<view class="shilitu">
					<image :src="dataAll.goods_image_text" mode=""></image>
				</view>
				<view class="flexcolumnbet" style="width: 66%;height: 180rpx;">
					<view class="xiaohei titletext fonweight xiankuan">{{dataAll.goods_name}}</view>
					<view class="xiaohui titletext nofonweight">积分抵扣：{{dataAll.score}}</view>
					<view class="xiaohui titletext nofonweight">实付金额：
						<text class="xiaohong titletext fonweight">{{dataAll.pay_price}}</text>
					</view>
					<view class="flexbetween" style="width: 100%">
						<view class="xiaohui titletext nofonweight margin_top1">*1</view>
						<view class="xiaohei titletext nofonweight margin_top1">总价：
							<text class="xiaohong titletext fonweight">{{dataAll.price}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mainpadding margin_top ffffff">
			<view class="titletext sanshier fonweight">买家信息</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">持卡人</view>
				<view class="strongtext">{{dataAll.pay_userinfo.nickname}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">手机号</view>
				<view class="flexleft">
					<view class="strongtext" @click="phone(dataAll.pay_userinfo.mobile)">{{dataAll.pay_userinfo.mobile}}</view>
					<u-icon name="phone" color="#2979ff" size="16"></u-icon>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff" v-if="dataAll.pay_status!=1">
			<view class="flexcenter">
				<image :src="dataAll.fk_image_text" mode="widthFix" @click="lbtpriview(0)" style="width: 200rpx;"></image>
			</view>
			<view class="titletext sanshier margin_top flexcenter fonweight">支付凭证</view>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="titletext sanshier fonweight">订单信息</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">积分抵扣：</view>
				<view class="xiaohong titletext fonweight">￥{{dataAll.score}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">实付金额：</view>
				<view class="xiaohong titletext fonweight">￥{{dataAll.pay_price}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">订单金额：</view>
				<view class="xiaohong titletext fonweight">￥{{dataAll.price}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">订单编号：</view>
				<view class="strongtext">{{dataAll.order_on}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">创建时间：</view>
				<view class="strongtext">{{dataAll.createtime_text}}</view>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding" v-if="dataAll.pay_status==2">
			<view class="flexright">
				<view class="listbtn xiaolan" v-if="dataAll.pay_status==2" @click="sureshowpay(listid)">确认收款</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid: "",
				dataAll: {},
				pageShow: false
			}
		},
		onLoad(options) {
			this.listid = options.id
		},
		onShow() {
			this.getDetail()
		},
		methods: {
			phone(p) {
				uni.makePhoneCall({
					phoneNumber: p.toString()
				}).catch((e) => {
					// console.log(e)  //用catch(e)来捕获错误{makePhoneCall:fail cancel}
				})
			},
			lbtpriview(index) {
				var i = [this.dataAll.fk_image_text]; //获取当前页面的轮播图数据
				//uniapp预览轮播图
				uni.previewImage({
					current: index, //预览图片的下标
					urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
				})
			},
			sureshowpay(id) {
				httpRequest.modal('提示', '请再次确认', true, (res) => {
					if (res) {
						httpRequest.request('/api/cccl/myMaiOrderDz', 'GET', {
							order_id: id
						}).then(res => {
							httpRequest.toast(res.msg)
							if (res.code == 1) {
								this.getDetail()
							}
						})
					}
				})
			},
			copycontent() {
				let text = this.dataAll.express_name + this.dataAll.express_no
				uni.setClipboardData({
					data: text, //要被复制的内容
					success: () => {
						//复制成功的回调函数
						httpRequest.toast("复制成功")
					}
				});
			},

			delitem(id) {
				httpRequest.modal('提示', '确认删除当前订单吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/scoregoods/delOrder', 'POST', {
							id
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg)
							if (res.code == 1) {
								setTimeout(() => {
									uni.navigateBack(1)
								}, 1000)
							}
						})
					}
				})
			},
			cancelitem(id) {
				httpRequest.modal('提示', '确认取消当前订单吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/scoregoods/cancelOrder', 'GET', {
							id
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg)
							if (res.code == 1) {
								this.getDetail()
							}
						})
					}
				})
			},
			getDetail() {
				httpRequest.request('/api/cccl/orderDetail', 'GET', {
					order_id: this.listid
				}, false, false, true).then(res => {
					this.dataAll = res.data
					this.pageShow = true
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	/deep/.u-count-down__text {
		color: #ff0000
	}

	page {
		background-color: #f9f9f9;
	}

	.shilitu {
		width: 200rpx;
		height: 160rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}
</style>